package com.dianwoba.core.datasource;

/**
 * 数据源切换线程容器
 * @author licf
 */
public class DataSourceHolder {
	
	private static final ThreadLocal<String> holder = new ThreadLocal<String>();
	
	private static void setDatasourceHolder(String dataSource) {
		holder.set(dataSource);   
	}
	
	public static void setSlave(final String dataSource){
		setDatasourceHolder(dataSource);
	}
	
	public static void setMaster(){
		clear();;   
	}
	
	public static String getDatasourceLookupKey() {
		return holder.get();
	}
	
	public static void clear() {   
		holder.remove();   
	}

}
